// 百度搜索功能
function searchBaidu(query) {
    if (query) {
        window.open('https://www.baidu.com/s?wd=' + encodeURIComponent(query), '_blank');
    }
}

// 谷歌搜索功能
function searchGoogle(query) {
    if (query) {
        window.open('https://www.google.com/search?q=' + encodeURIComponent(query), '_blank');
    }
}

// 绑定百度搜索框的回车事件
document.getElementById('baidu-search').addEventListener('keydown', function(event) {
    if (event.key === 'Enter') {
        event.preventDefault(); // 阻止默认行为
        const query = document.getElementById('baidu-search').value;
        searchBaidu(query);
    }
});

// 绑定谷歌搜索框的回车事件
document.getElementById('google-search').addEventListener('keydown', function(event) {
    if (event.key === 'Enter') {
        event.preventDefault(); // 阻止默认行为
        const query = document.getElementById('google-search').value;
        searchGoogle(query);
    }
});

// 检测是否为 PC 设备
function isPCDevice() {
    return !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
}

// 如果是 PC 设备，跳转到 index.html
if (isPCDevice()) {
    window.location.href = "index.html";
}